<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客首页</title>
</head>
<body>
    <div>
        <input type="text" placeholder="查找博客标题，摘要，内容，分类，作者" name="keyword">
        <input type="button" value="查找" onclick="query()">
        <input type="button" value="新增" onclick="add()">
    </div>
    <table id="tbData" border="soild">
        <tr>
            <th>id</th>
            <th>标题</th>
            <th>摘要</th>
            <th>内容</th>
            <th>分类</th>
            <th>作者</th>
            <th>操作</th>
        </tr>
        <tr class="rowData">
            <td>1</td>
            <td>2</td>
            <td>3</td>
            <td>4</td>
            <td>5</td>
            <td>6</td>
            <td><input type="button" value="修改" onclick="update()"></td>
            <td><input type="button" value="删除" onclick="del()"></td>
        </tr>
    </table>
    <script src="./js/jquery-3.6.0.min.js"></script>
    <script src="./config/baseUrl.js"></script>
    <script src="./js/api.js"></script>
    <script src="./js/init.js"></script>
    <script>
        //拿到所需的id跳转到编辑新增页面
        function update(id){
            location.href='./add.html?id='+id;
        }
        //拿到对应id进行删除
        function del(id){
            delBlog(id).then(data=>{
                if(data.code===1000){
                    let id=data.data.id
                    $(`[key=${id}]`).remove()
                }else{
                    alert(data.msg)
                }
            })
        }
        //拿到关键字
        function query(){
            let keyword=$('[name=keyword]').val()
            getListWithKeyword(keyword)
        }

    </script>
</body>
</html>